home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
arc42s.lbr
/
ARCTST.MQC
/
arctst.mac
Wrap
Text File
|
1985-08-04
|
3KB
|
67 lines
/* ARC - Archive utility - ARCTST
$define(tag,$$segment(@1,$$index(@1,=)+1))#
$define(version,Version $tag(
TED_VERSION DB =2.07), created on $tag(
TED_DATE DB =06/25/85) at $tag(
TED_TIME DB =10:12:15))#
$undefine(tag)#
$version
(C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
By: Thom Henderson
Description:
This file contains the routines used to test archive integrity.
Language:
Computer Innovations Optimizing C86
*/
#include <stdio.h>
#include "arc.h"
tstarc() /* test integrity of an archive */
{
int errs = 0; /* number of problems */
struct heads hdr; /* file header */
long arcsize, ftell(); /* archive size */
openarc(0); /* open archive for reading */
fseek(arc,0L,2); /* move to end of archive */
arcsize = ftell(arc); /* see how big it is */
fseek(arc,0L,0); /* return to top of archive */
while(errs<21 && !feof(arc))
{ if(fgetc(arc)!=$arcmark) /* check for the mark of ARC */
{ printf("%s is not an archive or is out of sync\n",arcname);
errs++;
}
else /* we can process it */
{ hdrver = fgetc(arc); /* get header version */
if(hdrver==0) /* special kludge for end marker */
break;
else if(hdrver==1) /* special kludge for old headers */
fread(&hdr,sizeof(hdr)-sizeof(long),1,arc);
else fread(&hdr,sizeof(hdr),1,arc);
if(ftell(arc)+hdr.size>arcsize)
{ printf("Archive truncated in file %s\n",hdr.name);
errs++;
break;
}
else if(unpack(arc,NULL,&hdr))
errs++;
else printf("File %s is okay\n",hdr.name);
}
}
if(errs>20)
printf("More than twenty errors detected\n");
else if(errs)
printf("%d errors detected\n",errs);
else printf("No errors detected\n");
}